package com.mab.apipassenger.controller;

import com.msb.internalcommon.request.VerificationCodeDTO;
import com.mab.apipassenger.service.VerificationCodeService;
import com.msb.internalcommon.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther: jiudianliu
 * @Date: 2023/3/17 - 03 - 17 - 15:09
 * @Description: com.mab.apipassenger.controller
 * @version: 1.0
 */
@RestController
public class VerificationCodeController {

    @Autowired
    private VerificationCodeService verificationCodeService;


    /**
     * 获取验证码
     * @param verificationCodeDTO
     * @return
     */
    @GetMapping("/verification-code")
    public ResponseResult verificationCode(@RequestBody VerificationCodeDTO verificationCodeDTO){
       String passengerPhone = verificationCodeDTO.getPassengerPhone();
        //System.out.println("接收到的手机号参数:" + passengerPhone);
        return verificationCodeService.generatorCode(passengerPhone);

    }

    /**
     * 校验验证码
     * @return
     */

    @PostMapping("/verification-code-check")
    public ResponseResult checkVerificationCode(@RequestBody VerificationCodeDTO verificationCodeDTO){
        String passengerPhone = verificationCodeDTO.getPassengerPhone();
        String verificationCode = verificationCodeDTO.getVerificationCode();
        System.out.println("手机号" + passengerPhone + "验证码" + verificationCode);
        return verificationCodeService.checkCode(passengerPhone,verificationCode) ;
    }
}
